package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.domain.SysPointpot;
import com.ruoyi.system.domain.SysPoints;
import com.ruoyi.system.mapper.SysMemberMapper;
import com.ruoyi.system.mapper.SysPointpotMapper;
import com.ruoyi.system.mapper.SysPointsMapper;
import com.ruoyi.system.response.TopicDoc;
import com.ruoyi.system.response.UserDoc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysDocMapper;
import com.ruoyi.system.domain.SysDoc;
import com.ruoyi.system.service.ISysDocService;
import com.ruoyi.common.core.text.Convert;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-09-04
 */
@Service
public class SysDocServiceImpl implements ISysDocService 
{
    @Autowired
    private SysDocMapper sysDocMapper;
    @Autowired
    private SysPointsMapper sysPointsMapper;
    @Autowired
    SysPointpotMapper sysPointpotMapper;
    @Autowired
    private SysMemberMapper sysMemberMapper;
    /**
     * 查询【请填写功能名称】
     * 
     * @param docid 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public SysDoc selectSysDocByDocid(Long docid)
    {
        return sysDocMapper.selectSysDocByDocid(docid);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param sysDoc 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<SysDoc> selectSysDocList(SysDoc sysDoc)
    {
        return sysDocMapper.selectSysDocList(sysDoc);
    }
    @Override
    public List<SysDoc> selectSysDocList1(SysDoc sysDoc)
    {
        return sysDocMapper.selectSysDocList1(sysDoc);
    }
    /**
     * 新增【请填写功能名称】
     * 
     * @param sysDoc 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertSysDoc(SysDoc sysDoc)
    {
        return sysDocMapper.insertSysDoc(sysDoc);
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param sysDoc 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateSysDoc(SysDoc sysDoc)
    {
        SysPoints sysPoints = sysPointsMapper.selectSysPointsById(4l);
        SysPointpot sysPointpot = new SysPointpot();
        sysPointpot.setIp(ShiroUtils.getIp());
        sysPointpot.setUserid(sysDoc.getUserid());
        sysPointpot.setType(4l);
        sysPointpot.setPoints(sysPoints.getPoints());
        sysPointpot.setDocid(sysDoc.getDocid());
        sysPointpotMapper.insertSysPointpot(sysPointpot);
        sysMemberMapper.updatePoint(sysDoc.getUserid(),sysPoints.getPoints());
        return sysDocMapper.updateSysDoc(sysDoc);

    }
    @Override
    public int editSysDoc(SysDoc sysDoc)
    {
        return sysDocMapper.updateSysDoc(sysDoc);
    }

    /**
     * 批量删除【请填写功能名称】
     * 
     * @param docids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteSysDocByDocids(String docids)
    {
        return sysDocMapper.deleteSysDocByDocids(Convert.toStrArray(docids));
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param docid 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteSysDocByDocid(Long docid)
    {
        return sysDocMapper.deleteSysDocByDocid(docid);
    }
    @Override
    public  void increaseReadcount(Long docid)
    {
        sysDocMapper.increaseReadcount(docid);
    }
    @Override
    public  void increaseDowncount(Long docid)
    {
        sysDocMapper.increaseDowncount(docid);
    }
    @Override
    public List<SysDoc> searchSysDocList(Long userid,String searchcol,String searchtext,String sortcol,String sorttext)
    {
      return   sysDocMapper.searchSysDocList(userid,searchcol,searchtext,sortcol,sorttext);
    }
    public List<SysDoc> searchSysDocListBysort(List<Long> type,String searchcol,int sort,int isvip,int isimp)
    {
        return   sysDocMapper.searchSysDocListBysort(type,searchcol,sort,isvip,isimp);
    }
    public List<SysDoc> searchSysDocListBykeyexten(String search,String exten)
    {
        return   sysDocMapper.searchSysDocListBykeyexten(search,exten);
    }
    @Override
    public TopicDoc selectByIdsSel(List<String> ids)
    {
        return  sysDocMapper.selectByIdsSel(ids);
    }
    @Override
    public List<SysDoc> selectByDocIds(List<String> ids)
    {
        return  sysDocMapper.selectByDocIds(ids);

    }
    @Override
    public List<UserDoc> selectUserDocs()
    {
        return sysDocMapper.selectUserDocs();
    }
}
